package cn.liao.me;

import com.alibaba.fastjson.JSON;
import org.springframework.util.StopWatch;

import java.util.concurrent.TimeUnit;

public class StopWatchDemo {
    public static void main(String[] args) throws Exception {
        StopWatch stopWatch = new StopWatch("任务-提交订单");
        stopWatch.start();
        TimeUnit.SECONDS.sleep(2);
        stopWatch.stop();
        System.out.println(JSON.toJSONString(stopWatch.getLastTaskInfo()));

        stopWatch.start();
        TimeUnit.SECONDS.sleep(3);
        stopWatch.stop();
        System.out.println(JSON.toJSONString(stopWatch.getLastTaskInfo()));

    }
}
